#! /usr/bin/python

import math
import time

t = time.time()

sq = [0, 1]
for i in range(2, 10**6):
    sq.append(i**2)

lookup = set(sq)
up = 10**6
small = 10**8

for i in range(920, up): #f
    for j in range(2, i): #e
	if (sq[i] - sq[j])%2 == 0:
	   x = (sq[i] + sq[j])/2
	   y = x -sq[j]
	   start = int(math.sqrt(x)) + 1
	   for k in range(start, i): #b 
	       if 2*x - sq[k] in lookup:
		  foundz = sq[k] - x
		  if y + foundz in lookup and y - foundz in lookup:	
	             print x + y + foundz
	             print time.time() - t
		     break 



